cmake_minimum_required (VERSION 3.18)
cmake_policy(SET CMP0079 NEW)

project("libProtonDoseEngine")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")

set(SOURCE_DIR ${CMAKE_SOURCE_DIR})
include("macro.cmake")

get_filename_component(DIPPER_ROOT_DIRECTORY ${SOURCE_DIR} DIRECTORY)
SET(PROJECT_OUTPUT_DIR "${DIPPER_ROOT_DIRECTORY}/output")
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR} )
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_OUTPUT_DIR}")
set(LIBRARY_OUTPUT_PATH "${PROJECT_OUTPUT_DIR}")
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  SET(CMAKE_INSTALL_PREFIX "${DIPPER_ROOT_DIRECTORY}/install"  CACHE PATH "set install directory" FORCE)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
add_definitions(-D_BIND_TO_CURRENT_VCLIBS_VERSION=1)
add_definitions(-DWIN32)
add_definitions(-DDTL_PLUGIN_SHARED_LIBS_EXPORT)

include_directories("${SOURCE_DIR}/libs/glm-0.9.8.4")
include_directories("${SOURCE_DIR}/libs/mongocxx-3.4.0/include/bsoncxx/v_noabi")
include_directories("${SOURCE_DIR}/libs/mongocxx-3.4.0/include/libbson-1.0")
include_directories("D:/projects/utils_3rd/boost_1_73_0") 


configure_files("${SOURCE_DIR}/libs/mongocxx-3.4.0/release" "${PROJECT_OUTPUT_DIR}/release")
configure_files("${SOURCE_DIR}/libs/mongocxx-3.4.0/debug" "${PROJECT_OUTPUT_DIR}/debug")

add_library(libProtonDoseEngine SHARED  
pdeDoseEngine.h
pdeDoseEngine.cpp
pdeVolume.h
pdeVolume.cpp
pdeStructSet.h
pdeStructSet.cpp
pdePlan.h
pdePlan.cpp
pdeDoseModel.h
pdeDoseModel.cpp
pdeLut.h
pdeLut.cpp
volume_utils.h
volume_utils.cpp
pdeFile.h
pdeFile.cpp
pdeRBE.h
pdeRBE.cpp
)

target_link_libraries(libProtonDoseEngine
debug  "${SOURCE_DIR}/libs/mongocxx-3.4.0/lib/debug/bsoncxx.lib"
debug  "${SOURCE_DIR}/libs/mongocxx-3.4.0/lib/debug/mongocxx.lib"
optimized "${SOURCE_DIR}/libs/mongocxx-3.4.0/lib/release/bsoncxx.lib"
optimized "${SOURCE_DIR}/libs/mongocxx-3.4.0/lib/release/mongocxx.lib"
)

subdirs(test)

# install package
FILE(GLOB head_files "${SOURCE_DIR}/*.h")
INSTALL(FILES ${head_files} DESTINATION "include")

FILE(GLOB dll_files1 "${PROJECT_OUTPUT_DIR}/release/*.dll")
INSTALL(FILES ${dll_files1} DESTINATION "bin/release")

FILE(GLOB dll_files "${PROJECT_OUTPUT_DIR}/debug/*.dll")
INSTALL(FILES ${dll_files} DESTINATION "bin/debug")

FILE(GLOB lib_files1 "${PROJECT_OUTPUT_DIR}/release/*.lib")
INSTALL(FILES ${lib_files1} DESTINATION "lib/release")

FILE(GLOB lib_files "${PROJECT_OUTPUT_DIR}/debug/*.lib")
INSTALL(FILES ${lib_files} DESTINATION "lib/debug")
